import time
from apscheduler.schedulers.blocking import BlockingScheduler
from SpiderAction.SinaSpider import getSinaNewsList
from SpiderAction.WeixinSpider import get_weixin_list
from pretreat_tools.send_data import screening_flag


def my_job1():
    """
    爬虫信息（微信）
    :return:
    """
    t1 = time.time()
    get_weixin_list()
    t2 = time.time()
    print("完成了微信爬虫信息工作", t2-t1)


def my_job2():
    """
    爬虫信息（新浪）
    :return:
    """
    getSinaNewsList()
    print("完成了微信新浪信息工作")


def my_job3():
    """
    筛选数据库，中文过滤、上传
    :return:
    """
    time.sleep(900)  # 滞后10分钟是600
    screening_flag()
    print("完成了过滤上传工作")


sched = BlockingScheduler()
sched.add_job(my_job1, 'interval', hours=1)  # seconds=5
sched.add_job(my_job2, 'interval', hours=1)  # hours=1
sched.add_job(my_job3, 'interval', hours=1)
sched.start()